<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<script src="js/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
        //发送 ajax请求：
        function json(){
            var name = $("#name").val();
            var pass = $("#pass").val();
            $.ajax({
                url: "login",
                type: "get",
                data: {
                    username: name,
                    password: pass
                },
                dataType: "JSON",
                success: function (data) {
                    console.log(data);
                   // var dsad = data.evey(data)
                   // var ds = data.indexOf(data)
                    if (data == "登录成功！") {
                        alert("登录成功")
                    }
                },
                error: function () {
                    console.log(11)
                }
            })
        }
</script>
<body>
    <div>
            <form  class="f1">
               <label>姓名：</label> <input id="name" type="text" value="">
               <label>密码：</label> <input id="pass" type="password" value="">
            </form>
            <button value="提交" onclick="json()">登录</button>
    </div>
</body>
</html>
